package com.shop2cn.iapi.coupon.testcase;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.coupon.parameter.CouponDto;
import com.shop2cn.iapi.coupon.parameter.getProductUsableSellerCouponsBean;
import com.shop2cn.iapi.coupon.service.getProductUsableSellerCouponsCall;
import com.shop2cn.iapi.couponmanage.parameter.SellerCreateBatchBean;
import com.shop2cn.iapi.couponmanage.service.SellerCreateBatchCall;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponShop2cnCallService;
import com.ymttest.business.service.CouponShop2cnMCallService;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.CouponShop2cn.coupon;
import com.ymttest.database.model.CouponShop2cn.couponbatch;
import com.ymttest.database.sqlwapper.CouponShop2cn.couponWapper;
import com.ymttest.database.sqlwapper.CouponShop2cn.couponbatchWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*获取商品可用的买手优惠券
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getProductUsableSellerCoupons{ 
	private static getProductUsableSellerCouponsBean bean;
	private static getProductUsableSellerCouponsCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商品可用的买手优惠券");
	}

	@Before
	public void caseUp() {
		bean=new getProductUsableSellerCouponsBean();
		call=new getProductUsableSellerCouponsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_001() {
		Logger.start(true,"获取商品可用的买手优惠券-买手优惠券币种与查询的一致");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_001_3() {
		Logger.start(true,"获取商品可用的买手优惠券-买手优惠券币种与传入的不一致");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency("USA");
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
//			List<String> couponlst=new ArrayList();
//			couponlst.add(couponCode);
			
			List<CouponDto> couponDtos = call.GetProductAvailablePlatformCouponResp().getCouponDtos();
			Logger.verifyEquals(0,couponDtos.size(), "验证返回couponDtos数量");
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_001_4() {
		Logger.start(true,"获取商品可用的买手优惠券-验证两个优惠券，其中一个与传入的不一致");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			sellerCreateBatchBean.setCurrency("USA");
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency("USA");
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			//couponlst.add(couponCode);
			couponlst.add(couponCode2);
			
			List<CouponDto> couponDtos = call.GetProductAvailablePlatformCouponResp().getCouponDtos();
			Logger.verifyEquals(1,couponDtos.size(), "验证返回couponDtos数量");
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_001_1() {
		Logger.start(true,"获取商品可用的买手优惠券-优惠券已使用");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			new couponWapper().setIsUsedByCouponCode(couponCode,1);
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			
			call.setData(bean);
			call.callService();	
			List<CouponDto> couponDtos = call.GetProductAvailablePlatformCouponResp().getCouponDtos();
			Logger.verifyEquals(0,couponDtos.size(), "验证返回couponDtos数量 等于0");
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_001_2() {
		Logger.start(true,"获取商品可用的买手优惠券-优惠券作废");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			new couponWapper().setIsUsedByCouponCode(couponCode,1);
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<CouponDto> couponDtos = call.GetProductAvailablePlatformCouponResp().getCouponDtos();
			Logger.verifyEquals(0,couponDtos.size(), "验证返回couponDtos数量 等于0");
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getProductUsableSellerCoupons_002() {
		Logger.start(true,"获取商品可用的平台优惠券列表-多张可聚合券(多张券一样，数量增加)");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall1 = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode1 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode1);
			couponlst.add(couponCode2);
			verifyData(Arrays.asList(couponlst.get(0)));
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getProductUsableSellerCoupons_003() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优惠券可用面额不等不聚合");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			SellerCreateBatchBean sellerCreateBatchBean2 = couponCallService.setDefaultSellerCreateBatchBean();	
			sellerCreateBatchBean2.setCouponAmount(new BigDecimal(5));
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
            couponlst.add(couponCode2);
            
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getProductUsableSellerCoupons_004() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优惠券使用面额不等不聚合");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			SellerCreateBatchBean sellerCreateBatchBean2 = couponCallService.setDefaultSellerCreateBatchBean();	
			sellerCreateBatchBean2.setOrderMinAmount(new BigDecimal(150));
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
            couponlst.add(couponCode2);
            
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getProductUsableSellerCoupons_006() {
		Logger.start(true,"获取商品可用的平台优惠券列表-优惠券使用结束时间不等不聚合");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			Calendar calendar2 = Calendar.getInstance(); // 得到日历
			calendar2.setTime(new Date());// 把当前时间赋给日历
			calendar2.add(Calendar.DAY_OF_MONTH, 3); // 设置为后十天
			Date dAfter = calendar2.getTime(); // 得到前一天的时间

			sellerCreateBatchBean.setAcquireEndTime(dAfter);
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			SellerCreateBatchBean sellerCreateBatchBean2 = couponCallService.setDefaultSellerCreateBatchBean();
			sellerCreateBatchBean2.setSellerId(sellerCreateBatchBean.getSellerId());
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean2);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
			couponlst.add(couponCode2);
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getProductUsableSellerCoupons_007() {
		Logger.start(true,"获取商品可用的平台优惠券列表-UserId空，正常错误");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
		//	bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
  			Logger.verifyEquals("1",call.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains(true,call.getString("message").contains("userId:请传入用户Id"), "验证返回message");
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_008() {
		Logger.start(true,"获取商品可用的买手优惠券-ProductCode为空，正常错误");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			bean.setUserId(userId);
			//bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
  			Logger.verifyEquals("1",call.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains(true,call.getString("message").contains("productCode:商品编号不能为空"), "验证返回message");
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_009() {
		Logger.start(true,"获取商品可用的买手优惠券-SellerId为空，返回错误");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
		//bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
  			Logger.verifyEquals("1",call.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains(true,call.getString("message").contains("sellerId:请传入买手Id"), "验证返回message");
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_010() {
		Logger.start(true,"获取商品可用的买手优惠券-ActivityId为空，返回错误");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			//bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_011() {
		Logger.start(true,"获取商品可用的平台优惠券列表-直播商品-JIRACONN-26114");
		try {
			int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String pid = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建商品：" + pid);
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(sellerId));
			LiveRoomCallService.AddProductsToLive(createlive.getId(), createlive.getUserId(), pid);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), createlive.getUserId());
			
			String productId = pid;
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			sellerCreateBatchBean.setSellerId(sellerId);
			sellerCreateBatchBean.setCouponType((byte)4);
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			Thread.sleep(5000);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(createlive.getId());
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_012() {
		Logger.start(true,"获取商品可用的买手优惠券-直播商品-没有可用的优惠券-JIRACONN-26114");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
//			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
//			
			Integer userId=TestDataManager.getRandomIntNum(8);
//			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			Logger.verifyEquals(true,call.GetProductAvailablePlatformCouponResp().getCouponDtos().size()==0, "验证返回couponDtos数量等于0");
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_013() {
		Logger.start(true,"获取商品可用的买手优惠券-直播商品，但是不含有仅直播时使用的优惠券-返回普通平台优惠券-JIRACONN-26114");
		try {
			int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String pid = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建商品：" + pid);
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(sellerId));
			LiveRoomCallService.AddProductsToLive(createlive.getId(), createlive.getUserId(), pid);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), createlive.getUserId());
			
			String productId = pid;
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手优惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			SellerCreateBatchBean sellerCreateBatchBean2 = couponCallService.setDefaultSellerCreateBatchBean();	
			sellerCreateBatchBean2.setSellerId(sellerCreateBatchBean.getSellerId());
			//sellerCreateBatchBean2.setCouponType((byte)4);
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean2);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean2.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			
			List<String> couponlst=new ArrayList();
			couponlst.add(couponCode);
			couponlst.add(couponCode2);
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_014() {
		Logger.start(true,"获取商品可用的买手优惠券-仅直播优惠券+普通买手优惠券，商品参加直播，仅直播优惠券面额 大于 普通平台优惠券面额,返回仅直播优惠券-JIRACONN-26114");
		try {
			int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String pid = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建商品：" + pid);
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(sellerId));
			LiveRoomCallService.AddProductsToLive(createlive.getId(), createlive.getUserId(), pid);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), createlive.getUserId());
			
			String productId = pid;
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手优惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			SellerCreateBatchBean sellerCreateBatchBean2 = couponCallService.setDefaultSellerCreateBatchBean();	
			sellerCreateBatchBean2.setSellerId(sellerCreateBatchBean.getSellerId());
			sellerCreateBatchBean2.setCouponType((byte)4);
			sellerCreateBatchBean2.setCouponAmount(new BigDecimal(1.5));
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean2);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean2.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			
			List<String> couponlst=new ArrayList();
			//couponlst.add(couponCode);
			couponlst.add(couponCode2);
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_015() {
		Logger.start(true,"获取商品可用的买手优惠券-仅直播优惠券+普通买手优惠券，商品参加直播，仅直播优惠券面额 等于 普通平台优惠券面额,返回仅直播优惠券-JIRACONN-26114");
		try {
			int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String pid = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建商品：" + pid);
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(sellerId));
			LiveRoomCallService.AddProductsToLive(createlive.getId(), createlive.getUserId(), pid);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), createlive.getUserId());
			
			String productId = pid;
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手优惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			SellerCreateBatchBean sellerCreateBatchBean2 = couponCallService.setDefaultSellerCreateBatchBean();	
			sellerCreateBatchBean2.setSellerId(sellerCreateBatchBean.getSellerId());
			sellerCreateBatchBean2.setCouponType((byte)4);
			SellerCreateBatchCall sellerCreateBatchCall2 = couponCallService.SellerCreateBatch(sellerCreateBatchBean2);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			String couponCode2 = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall2.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean2.getSellerId());
			bean.setActivityId(1);
			bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
			
			List<String> couponlst=new ArrayList();
			//couponlst.add(couponCode);
			couponlst.add(couponCode2);
			verifyData(couponlst);
           
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductUsableSellerCoupons_016() {
		Logger.start(true,"获取商品可用的买手优惠券-传入的currency为空");
		try {
			String productId = TestDataManager.getRandomNum(8);
			CouponShop2cnMCallService couponCallService = new CouponShop2cnMCallService();
			CouponShop2cnCallService CouponShop2cnCallService = new CouponShop2cnCallService();
			// 买手惠券-链接
			SellerCreateBatchBean sellerCreateBatchBean = couponCallService.setDefaultSellerCreateBatchBean();	
			SellerCreateBatchCall sellerCreateBatchCall = couponCallService.SellerCreateBatch(sellerCreateBatchBean);
			
			Integer userId=TestDataManager.getRandomIntNum(8);
			String couponCode = CouponShop2cnCallService.receiveCouponInfo(sellerCreateBatchCall.getBatchCode(), userId);
			
			bean.setUserId(userId);
			bean.setProductCode(productId); 
			bean.setSellerId(sellerCreateBatchBean.getSellerId());
			bean.setActivityId(1);
			//bean.setCurrency(sellerCreateBatchBean.getCurrency());
			bean.setCurrencySymbol("¥");
			call.setData(bean);
			call.callService();	
//			List<String> couponlst=new ArrayList();
//			couponlst.add(couponCode);
//			verifyData(couponlst);
           
  			Logger.verifyEquals("1",call.getString("statusCode"), "验证返回code");
  			Logger.verifyIsContains(true,call.getString("message").contains("货币单位不能为空"), "验证返回message");
  			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	private void verifyData(List<String> couponlst)
	{
		List<CouponDto> couponDtos = call.GetProductAvailablePlatformCouponResp().getCouponDtos();
		Logger.verifyEquals(true,couponDtos.size()==couponlst.size(), "验证返回couponDtos数量");
		int i=0;
		for (CouponDto couponDto : couponDtos) {
			String couponCode=couponlst.get(i);
			if(couponDto.getCouponCode().equals(couponCode))
			{
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	  			Logger.verifyEquals(0,couponDto.getLimitActivityIds().size(), "验证返回limitActivityIds");
	  			coupon coupon=new couponWapper().selectBycouponCode(couponCode).get(0);
	  			couponbatch batch=new couponbatchWapper().selectByPrimaryKey(coupon.getBatchId());
	  			Logger.verifyEquals(batch.getReceiveTimesPerUser(),couponDto.getQuantity(), "验证返回quantity");
	  			Logger.verifyEquals(batch.getUseConditionType(),couponDto.getLimitType(), "验证返回limitType");
	  			Logger.verifyEquals(batch.getCouponValue().stripTrailingZeros(),couponDto.getCouponValue(), "验证返回couponValue");
	  			Logger.verifyEquals(batch.getMinOrderValue().stripTrailingZeros(),couponDto.getMinOrderValue(), "验证返回minOrderValue");
	  			Logger.verifyEquals(coupon.getCouponCode(),couponDto.getCouponCode(), "验证返回CouponCode");
	  			Logger.verifyEquals(formatter.format(coupon.getValidStart()),formatter.format(couponDto.getValidStart()), "验证返回validStart");
	  			Logger.verifyEquals(formatter.format(coupon.getValidEnd()),formatter.format(couponDto.getValidEnd()), "验证返回validEnd");
	  			Logger.verifyEquals(batch.getCouponType(),couponDto.getCouponType(), "验证返回couponType");
	  			Logger.verifyEquals(couponDto.getBatchId(),coupon.getBatchId(), "验证返回BatchId");
	  			Logger.verifyEquals(couponDto.getBatchCode(),batch.getBatchCode(), "验证返回BatchCode");
			}
			i++;
		}
	}
}